<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<title><s:property value="ev_title" />
</title>
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<link rel="stylesheet" href="${aier_css_url}b.css" />
<link rel="stylesheet" type="text/css" href="${aier_css_url}jp/1.css" />
<link href="${aier_css_url}jq/jq.css" rel="Stylesheet" />
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}/ui.css" />
<link rel="stylesheet" href="${aier_css_url}comm/text.css" />
<link rel="stylesheet" href="${aier_css_url}admin/admin.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/1.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/afu.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/hh/ui.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/arrayList.js"></script>
<script type="text/javascript" src="${aier_js_url}jc/cj.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}comm/text.js"></script>
</head>
<body style="background-color: #EEF2FB;">
    
    <div style="background-color: #EEF2FB;width: 100%;height: 700px;">
                    <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">门禁设备分派</a></li>
                    </ul>
                    <div id="tabs-1" style="height: 500px;">
                        <div class="d_content" style="height: 500px;overFlow-x: hidden;overFlow-y: auto; ">
							<table style="width:90%;height: 100%;">
								<tr><td><s:action name="proxy_choice" namespace="/zxadmin" executeResult="true"></s:action></td></tr>
								<tr><td>未分派的设备</td></tr>
								<tr><td><div id="enDisDataDiv"></div></td></tr>
								<tr><td><div id=icCdate class="jqpage"></div></td></tr>
								<tr><td>已分派的设备</td></tr>
								<tr><td><div id="enalreadyDiv"></div></td></tr>
								<tr><td><div id=icCdate1 class="jqpage"></div></td></tr>
							</table>
					   </div>
					</div>
					</div>
    </div>

</body>



<script type="text/javascript">
$("#tabs").tabs();
	//显示信息
	function enDisolayDatas(p) {
		var fun = function(data) {
			var temp = "<table width='100%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>"
					  +"<tr><td colspan=10 bgcolor='#CCFF00'>设备信息</td></tr><tr><td width='15%'>设备sn</td><td width='15%'>状态</td><td width='15%'>描述</td>"
					  +"<td width='20%'>是否开启拍照</td><td width='20%'>设备厂家</td><td colspan=2 width='30%'>操作</td></tr>";	
			if (data.s == 1 && undefined != data.enlist
                        && data.enlist.length > 0) { 
				for ( var i = 0; i < data.enlist.length; i++) {
					var tsn = data.enlist[i];
					if (tsn.vdstate == 11) {
						tsn.vdstate = "都拍照";
					} else if (tsn.vdstate == 0) {
						tsn.vdstate = "不拍照";
					} else if (tsn.vdstate == 10) {
						tsn.vdstate = "进门拍照";
					} else if (tsn.vdstate == 1) {
						tsn.vdstate = "出门拍照";
					}

					if (tsn.state == 10) {
						tsn.state = "启用";
					} else if (tsn.state == 0) {
						tsn.state = "停用";
					}
					temp += "<tr><td>"+tsn.sn+"</td><td>"+tsn.state+"</td><td>"+tsn.des+"</td><td>"+tsn.vdstate+"</td><td>"+data.es[tsn.supplier]
							+"</td><td><input type='button' class='recordsbut2' value='选择' onclick='selectDIV("+tsn.eid+")'/></td></tr>"
							;

				}
			}
			
			$("#icCdate").pager({
				pagenumber : data.page,
				pagecount : data.page_count,
				buttonClickCallback : function(page) {
					enDisolayDatas(page);
				}
			});
			temp += "</table>";
			$('#enDisDataDiv').html(temp);

		};
		exeAjax(
				ajaxUrl("${aier_url}zxadminjs/entr_selectUnassignEntrance${aier_suffix}"),
				fun, {
				"page" : p,
				});

	}
	//显示已分派的门禁设备
	function enAlreadyAssign(p) {
		var fun = function(data) {
			var temp = "<table width='100%' border='1' bordercolor='#a0c6e5' style='border-collapse:collapse;' class='tableSiz1'>"
					  +"<tr><td colspan=10 bgcolor='#CCFF00'>设备信息</td></tr><tr><td width='15%'>设备sn</td><td width='15%'>状态</td><td width='15%'>描述</td>"
					  +"<td width='20%'>是否开启拍照</td><td width='20%'>设备厂家</td><td colspan=2 width='30%'>操作</td></tr>";	
			if (data.s == 1 && undefined != data.alreadyassignlist
				&& data.alreadyassignlist.length > 0) { 
				for ( var i = 0; i < data.alreadyassignlist.length; i++) {
					var tsn = data.alreadyassignlist[i];
					if (tsn.vdstate == 11) {
						tsn.vdstate = "都拍照";
					} else if (tsn.vdstate == 0) {
						tsn.vdstate = "不拍照";
					} else if (tsn.vdstate == 10) {
						tsn.vdstate = "进门拍照";
					} else if (tsn.vdstate == 1) {
						tsn.vdstate = "出门拍照";
					}

					if (tsn.state == 10) {
						tsn.state = "启用";
					} else if (tsn.state == 0) {
						tsn.state = "停用";
					}
					temp += "<tr><td>"+tsn.sn+"</td><td>"+tsn.state+"</td><td>"+tsn.des+"</td><td>"+tsn.vdstate+"</td><td>"+data.es[tsn.supplier]
							+"</td><td><input type='button' value='回收' class='recordsbut2' onclick='Resuse("+tsn.eid+")'/></td></tr>";

				}
			}
			$("#icCdate1").pager({
				pagenumber : data.page,
				pagecount : data.page_count,
				buttonClickCallback : function(page) {
					enAlreadyAssign(page);
				}
			});
			temp += "</table>";
			$('#enalreadyDiv').html(temp);

		};
		exeAjax(
				ajaxUrl("${aier_url}zxadminjs/entr_selectAlreadyassignEntrance${aier_suffix}"),
				fun, {
				"page" : p,
				});

	}
	function selectDIV(eid) {

		var fun = function(data) {
			if (1 == data.s) {
				alert("分派成功");
				enDisolayDatas();
				enAlreadyAssign();
			} else
				alert("分派失败");
		};
		exeAjax(ajaxUrl("${aier_url}zxadminjs/entr_updatepid${aier_suffix}"),
				fun, {
					"eid" : eid,
					"pid" : s_pid

				});

	}
	function Resuse(eid) {

		var fun = function(data) {
			if (1 == data.s) {
				alert("回收成功");
				enDisolayDatas();
				enAlreadyAssign();
			} else
				alert("回收失败");
		};
		exeAjax(
				ajaxUrl("${aier_url}zxadminjs/entr_updatenullpid${aier_suffix}"),
				fun, {
					"eid" : eid,
				});

	}

	enDisolayDatas();
	enAlreadyAssign();
</script>

</html>